package com.gxa.employment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gxa.employment.entity.pojo.Delay;
import com.gxa.employment.entity.pojo.Student;
import com.gxa.employment.entity.dto.FilterConditionDto;
import com.gxa.employment.entity.vo.StuClazzIvwVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * <p>
 * 学生信息表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-03-25
 */
@Mapper
public interface StudentMapper extends BaseMapper<Student> {

    /**
     * 模糊查询学生信息
     */
    List<StuClazzIvwVo> getStudentInfo();

//    List<StuClazzIvwVo> selectStudentsByConditions(FilterConditionDto filterConditionDto);

    /**
     * 更新学生的就业状态
     *
     * @param stuId 学生ID
     * @param status 新的就业状态
     */
    Integer updateStudentStatus(@Param("stuId") Integer stuId, @Param("status") String status);

    /**
     * 插入暂停就业记录
     *
     * @param delay 暂停就业信息
     */
    @Insert("INSERT INTO tb_delay (stu_id, delay_reason, delay_date, delay_start, created, updated, deleted) VALUES (#{stuId}, #{delayReason}, #{delayDate}, #{delayStart}, NOW(), NOW(), 0)")
    Integer insertDelayRecord(Delay delay);

    // Mapper 方法：检查是否存在推迟记录
    @Select("SELECT COUNT(*) FROM tb_delay WHERE stu_id=#{stuId} AND deleted=0")
    Integer hasDelayRecord(@Param("stuId") Integer stuId);
}
